﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucProductAddUpdate.ascx.cs" Inherits="MyWeb.Admin.Usercontrols.ucProductManager" %>
<%@ Register TagPrefix="CKEditor" Namespace="CKEditor.NET" Assembly="CKEditor.NET, Version=3.6.4.0, Culture=neutral, PublicKeyToken=e379cdf2f8354999" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<div id="page-content">
    <div id="page-header">
        <h1>
            <asp:Label ID="lblPageHeader" runat="server" Text="Chi tiết sản phẩm"></asp:Label></h1>
    </div>
    <div class="container">
        <div class="box-header">
            <asp:Label ID="lblBoxHeader" runat="server" Text="Thông tin chi tiết"></asp:Label>
        </div>
        <div class="box">
            <table id="myTable" class="admintable" cellspacing="1" width="100%">
                <tr>
                    <td>
                    <td colspan="4">
                        <asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="Red" />
                    </td>
                </tr>
                <tr style="background-color: gainsboro">
                    <td class="key">
                    <td style="text-align: right">
                        <asp:Label ID="Label9" runat="server" Text="NHÓM SẢN PHẨM" Font-Bold="True" CssClass="auto-style4"></asp:Label></td>
                    <td>
                        <asp:DropDownList ID="ddlGroupProduct" runat="server" Width="200px">
                        </asp:DropDownList>
                    </td>
                    <td style="text-align: right">
                        <asp:Label ID="Label10" runat="server" Text="PHÂN LOẠI" Font-Bold="True" CssClass="auto-style4"></asp:Label></td>
                    <td>
                        <asp:DropDownList ID="ddlDistribution" runat="server" Width="200px">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        <asp:Label ID="Label5" runat="server" Text="Mã sản phẩm:" Font-Bold="True"></asp:Label></td>
                    <td colspan="4">
                        <asp:TextBox ID="txtId" runat="server" Width="100px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Mã sản phẩm không được bỏ trống" ControlToValidate="txtId" ForeColor="Red">(*)</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        <asp:Label ID="Label1" runat="server" Text="Tên sản phẩm" Font-Bold="True"></asp:Label></td>
                    <td colspan="4">
                        <asp:TextBox ID="txtName" runat="server" Width="300px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Tên sản phẩm không được bỏ trống" ControlToValidate="txtName" ForeColor="Red">(*)</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        <asp:Label ID="lblmk" runat="server" Text="Chi tiết:" Font-Bold="True"></asp:Label></td>
                    <td colspan="4">
                        <CKEditor:CKEditorControl ID="CKEditor1" runat="server" Height="250px"></CKEditor:CKEditorControl></td>
                </tr>
                <tr>
                    <td class="key">
                        <asp:Label ID="Label2" runat="server" Text="Giá:" Font-Bold="True"></asp:Label></td>
                    <td colspan="4">
                        <asp:TextBox ID="txtPrice" runat="server" Width="100px" TextMode="Number"></asp:TextBox>
                        <asp:Label ID="Label7" runat="server" Text="(VNĐ)" Font-Bold="False"></asp:Label></td>
                </tr>
                <tr>
                    <td class="key">
                        <asp:Label ID="Label3" runat="server" Text="Giá mới:" Font-Bold="True"></asp:Label></td>
                    <td colspan="4">
                        <asp:TextBox ID="txtPriceNew" runat="server" Width="100px" TextMode="Number"></asp:TextBox>
                        <asp:Label ID="Label8" runat="server" Text="(VNĐ)" Font-Bold="False"></asp:Label></td>
                </tr>
                <tr>
                    <td class="key">
                        <asp:Label ID="Label4" runat="server" Text="Ngày nhập:" Font-Bold="True"></asp:Label></td>
                    <td colspan="4">
                        <asp:TextBox ID="txtDate" runat="server" Width="150px" TextMode="DateTime"></asp:TextBox>
                        <asp:CalendarExtender ID="txtDate_CalendarExtender" runat="server" TargetControlID="txtDate">
                        </asp:CalendarExtender>
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        <asp:Label ID="lblremk" runat="server" Text="Hình ảnh:" Font-Bold="True"></asp:Label></td>
                    <td class="auto-style3" colspan="4">
                        <asp:TextBox ID="txtImage" runat="server" Width="300px"></asp:TextBox>
                        <input type="button" class="button" value="..." onclick="BrowseServer();" /><asp:Button ID="btnUploadImg" runat="server" CausesValidation="False" CssClass="button" OnClick="btnUploadImg_Click" Text="Tải lên" />
                        <asp:GridView ID="gvImage" CssClass="GridStyle" runat="server" Width="350px" AutoGenerateColumns="False" PageSize="3" AllowPaging="True" OnPageIndexChanging="gvImage_PageIndexChanging" OnRowCommand="gvImage_RowCommand" DataKeyNames="Image">
                            <Columns>
                                <asp:TemplateField HeaderText="Hình ảnh">
                                    <HeaderStyle Width="60px" HorizontalAlign="Center"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                    <ItemTemplate>
                                        <asp:Image runat="server" ID="imgImage" ImageUrl='<%#Eval("Image") %>' Width="50px" Height="50px" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Ảnh đại diện">
                                    <HeaderStyle Width="90px" HorizontalAlign="Center"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                    <ItemTemplate>
                                        <asp:RadioButton ID="rdoCheck" runat="server" onclick="javascript:CheckOtherIsCheckedByGVID(this);" />
                                        <asp:HiddenField ID="HfImg" runat="server"
                                            Value='<%# Eval("Image") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtDelete" runat="server" CommandName="Delete" CommandArgument='<%#Eval("Image") %>' CausesValidation="False">Xóa</asp:LinkButton>
                                    </ItemTemplate>
                                    <HeaderStyle Width="50px"></HeaderStyle>
                                    <ItemStyle CssClass="cbxCheck" HorizontalAlign="Center"></ItemStyle>
                                </asp:TemplateField>
                            </Columns>
                            <HeaderStyle CssClass="GridTitle" />
                            <RowStyle CssClass="RowStyle" />
                            <AlternatingRowStyle CssClass="AlternateRowStyle" />
                            <EmptyDataRowStyle HorizontalAlign="Center" />
                            <PagerStyle CssClass="Paging" HorizontalAlign="Left" />
                            <PagerSettings Mode="NumericFirstLast" />
                            <EmptyDataTemplate>
                                Dữ liệu ảnh rỗng !
                            </EmptyDataTemplate>
                        </asp:GridView>
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        <asp:Label ID="Label6" runat="server" Text="Thứ tự:" Font-Bold="True"></asp:Label></td>
                    <td colspan="4">
                        <asp:TextBox ID="txtOrder" runat="server" Width="100px" TextMode="Number"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage=" Thứ tự không được bỏ trống" ControlToValidate="txtOrder" ForeColor="Red">(*)</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        <asp:Label ID="txtCpmg" runat="server" Text="Công bố:" Font-Bold="True"></asp:Label></td>
                    <td colspan="4">
                        <asp:CheckBox ID="ckCongbo" runat="server" Checked="True" />
                    </td>
                </tr>
            </table>
        </div>
        <div>
            <asp:Button ID="btnSave" runat="server" CssClass="button" Text="Lưu" OnClick="btnSave_Click" />
            <asp:Button ID="btnSaveAndNew" runat="server" CssClass="button" Text="Lưu & Thêm mới" OnClick="btnSaveAndNew_Click" />
            <asp:Button ID="btnCancelAdd" runat="server" CausesValidation="False" CssClass="button" Text="Đóng" OnClick="btnCancelAdd_Click" />
        </div>
    </div>
</div>
<script src="../ckfinder/ckfinder.js"></script>
<script type="text/javascript">

    function BrowseServer() {
        var finder = new CKFinder();
        finder.basePath = "ckfinder";
        finder.selectActionFunction = SetFileField;
        finder.popup();
    }

    function SetFileField(fileUrl) {
        document.getElementById('ContentPlaceHolder1_ctl00_txtImage').value = fileUrl;
    }
    function CheckOtherIsCheckedByGVID(spanChk) {

        var isChecked = spanChk.checked;
        if (isChecked) {
            spanChk.parentElement.parentElement.style.backgroundColor = 'rgb(207, 221, 207)';
        }
        var currentRdbId = spanChk.id;
        var chk = spanChk;
        var parent = document.getElementById("<%=gvImage.ClientID%>");

        var items = parent.getElementsByTagName('input');
        for (var i = 0; i < items.length; i++) {
            if (items[i].id != currentRdbId && items[i].type == "radio") {
                if (items[i].checked) {
                    items[i].checked = false;
                    items[i].parentElement.parentElement.style.backgroundColor = 'white'
                    items[i].parentElement.parentElement.style.color = 'black';
                }
            }
        }
    }
</script>
